package com.polaris.live.utils.sensor.module

import androidx.appcompat.app.AppCompatActivity
import com.polaris.live.common.mvvm.activity.BaseVmActivity
import com.polaris.live.popup.GlobalPopupManager
import com.polaris.live.ui.luckybag.fragment.dialog.LuckyBagMessageDialogFragment
import com.polaris.live.ui.message.fragment.dialog.MessageSessionDialogFragment
import com.polaris.live.utils.fragment.showNewDialogFragment
import com.polaris.live.utils.sensor.base.DialogModule
import com.polaris.live.utils.sensor.base.FunctionModule
import com.polaris.live.utils.sensor.base.IModule

/**
 * PageToolsModule
 *
 * @author Created by lucas on 2023/10/28 14:07
 * @since 1.0.0
 */
class PageToolsModule(
    private val context: AppCompatActivity
) : DialogModule(context) {

    override val title: String
        get() = "Page Tools"

    override fun createModules(): Array<IModule> = arrayOf(
        FunctionModule(mContext, "Nested Message", {
            mContext.supportFragmentManager.showNewDialogFragment(
                MessageSessionDialogFragment(isReusable = false),
                MessageSessionDialogFragment.FRAGMENT_TAG
            )
        }),
        FunctionModule(mContext, "Recharge Dialog", {
            if (context is BaseVmActivity<*>) {
                GlobalPopupManager.showRechargePopup(context, context.mViewModel, isNeedBottom = false)
            }
        }),
        FunctionModule(mContext, "LuckyBag Dialog", {
            mContext.supportFragmentManager.showNewDialogFragment(
                LuckyBagMessageDialogFragment(),
                LuckyBagMessageDialogFragment.FRAGMENT_TAG
            )
        })
    )
}